package com.aabte.design2.behavioral.chain.v3;

import lombok.Data;

/**
 * 简单组件的基础类
 *
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
@Data
public abstract class Component implements ComponentWithContextualHelp {

    private int x;
    private int y;
    private int width;
    private int height;

    private String tooltipText;

    protected Container container;

    public Component() {
    }

    public Component(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    @Override
    public void showHelp() {
        if (tooltipText != null) {
            System.out.println("tooltipText = " + tooltipText);
        } else {
            container.showHelp();
        }
    }
}
